﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Controls_Menu_Siderbar_Left : System.Web.UI.UserControl
{
    AccessData acc = new AccessData();
    protected void Page_Load(object sender, EventArgs e)
    {
        DataTable dt = acc.GetTable("select * from Menu where MenuParent=0");
        Repeater1.DataSource = dt;
        Repeater1.DataBind();
    }

    protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        
        DataRowView dv = e.Item.DataItem as DataRowView;
        if (dv != null)
        {
            Repeater repeater2 = e.Item.FindControl("Repeater2") as Repeater;
            int idMenu = (int)dv.Row["MenuID"];
            DataTable dt = acc.GetTable("select * from Menu where MenuParent=" + idMenu);
            repeater2.DataSource = dt;
            repeater2.DataBind();
        }
    }
    protected void Repeater2_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {

        DataRowView dv = e.Item.DataItem as DataRowView;
        if (dv != null)
        {
            Repeater repeater3 = e.Item.FindControl("Repeater3") as Repeater;
            int idMenu = (int)dv.Row["MenuID"];
            DataTable dt = acc.GetTable("select * from Menu where MenuParent=" + idMenu);
            repeater3.DataSource = dt;
            repeater3.DataBind();
        }
    }
}